//package com.cf.data.serve.mq;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.cf.data.serve.utils.UUIDGenerator;
//import lombok.extern.slf4j.Slf4j;
//import com.cf.data.serve.entity.HkAlarmFail;
//import com.cf.data.serve.entity.HkAlarmSuccess;
//import com.cf.data.serve.entity.HkNvrAlarm;
//import com.cf.data.serve.service.HkAlarmFailService;
//import com.cf.data.serve.service.HkAlarmSuccessService;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
///**
// * @author cuixi
// * @description: 海康事件（比对事件）消费者
// * @date 2024/7/31
// */
//
//@Component
//@RabbitListener(queues = "alarm_comparison_queue")
//@Slf4j
//public class ComparisonAlarmReceiver {
//
//    @Autowired
//    private HkAlarmSuccessService hkAlarmSuccessService;
//
//    @Autowired
//    private HkAlarmFailService hkAlarmFailService;
//
//    @RabbitHandler
//    public void process(String message) {
//        //获取事件接收对象，储存到数据库
//        JSONObject jsonObject = JSONObject.parseObject(message);
//        // 2是失败状态
//        if ("2".equals(jsonObject.getString("eventStatus"))) {
//            log.info("接收[人脸比对失败]消息：" + JSON.toJSONString(message));
//            HkAlarmFail hkAlarmFail = JSONObject.parseObject(message, HkAlarmFail.class);
//            hkAlarmFail.setId(UUIDGenerator.generate());
//            hkAlarmFailService.save(hkAlarmFail);
//
//        } else {
//            log.info("接收[人脸比对成功]消息：" + JSON.toJSONString(message));
//            HkAlarmSuccess hkAlarmSuccess = JSONObject.parseObject(message, HkAlarmSuccess.class);
//            hkAlarmSuccess.setId(UUIDGenerator.generate());
//            hkAlarmSuccessService.save(hkAlarmSuccess);
//
//        }
//
//    }
//
//}
